<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>搜索显示页面</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<!-- 引入组件 -->
		<script src="../../js/vue.min.js"></script>
		<script src="../../js/vue-lazyload.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/vant.min.js"></script>
		<script src="html5plus://ready"></script>
		<script src="../../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="../../js/fanhui.js" ></script>
		<style>
			li{
				list-style: none;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<header>
				<van-nav-bar @click-left="onClickLeft" style="background-color: red;">
					<van-icon slot="left" name="arrow-left" color="white"></van-icon>
					<label slot="title" style="color: white;">搜索内容</label>
				</van-nav-bar>
			</header>
			<section>
			<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
				<van-row>						
					<van-col span="24" >							
						<li v-for="(item, index) in list" :name="item.id">
							<van-card :num="item.count" :price="item.RealPrice" :origin-price="item.MarketPrice" :title="item.Name" @click="onclick(item.Id)">
								<img slot="thumb" src="../../img/520.jpg" />
								<span slot="footer">
									<label style="padding-right: 20%;">累计销售{{item.VirtualSaleCount}}</label>
									<label>{{item.BrowseCount}}次浏览</label>
								</span>
							</van-card>
						</li>						
					</van-col>
				</van-row>
				</van-pull-refresh>
			</section>	
		</div>
		
		<script type="text/javascript">
			var vm=new Vue({
				el:'#app',
				data:{
					list: [],
					finished: false,
					isLoading: false
				},
				created:function(){
					var _this=this;
					var w = plus.webview.currentWebview();
					console.info(w.name);
					ajax({
						url: "http://dsapi.ysd3g.com/api/GoodsSearch",
						dataType: "jsonp",
						data: {
							name:w.name
						},
						success: function(res) {
							console.log(res);
							vm.list = res.Data;							
							console.log(_this.list);								
						}
					});
					if(w.name==""){
						ajax({
							url: "http://dsapi.ysd3g.com/api/IndexGoodsData",
							dataType: "jsonp",
							data: {
								p: 1
							},
							success: function(res) {
								//console.log(res);
								vm.list = res.Data;
								//console.log(_this.IndexGoodsData);
								var hm = plus.webview.getWebviewById("home");
								hm.reload(true);
							}
						});
					}
 				},
				methods:{
					onclick:function(id){
						var del=plus.webview.create("../details.html","id",{},{shopId:id});
						plus.webview.show(del);
					},
					onClickLeft:function(){//返回
						plus.webview.close(plus.webview.currentWebview(),"slide-out-left");
					},
					onRefresh: function() {						
						setTimeout(() => {
							this.$toast('刷新成功');
							this.isLoading = false;
						}, 500);
					},
				}
			})
		</script>
	</body>
</html>